package utils

import (
	"encoding/json"
	"io/ioutil"
	"zinx/ziface"
	"fmt"
)

type GlobalObj struct {
	TcpServer ziface.IServer
	Host string
	TcpPort int
	Name string
	Version string
	MaxPacketSize uint32
	MaxConn int
}

var GlobalObject *GlobalObj

func (g *GlobalObj) Reload() {
	data,err := ioutil.ReadFile("conf/zinx.json")
	if err != nil {
		panic(err)
	}
	fmt.Println(data)
	err = json.Unmarshal(data,&GlobalObject)
	if err != nil {
		panic(err)
	}
}

func init() {
	GlobalObject = &GlobalObj {
		Name: "ZinxServerApp",
		Version: "v0.4",
		TcpPort : 7777,
		Host : "0.0.0.0",
		MaxConn : 12000,
		MaxPacketSize:4096,
	}
	GlobalObject.Reload()
}
